package com.globallogic.learning.kozius.entity;

import com.globallogic.learning.kozius.res.AuditoriumType;

/**
 * Class describe an auditorium which is used for a seminar
 * <p/>
 * Created by sergii.koziumynskyi on 2/4/14.
 */
public final class Auditorium {
    public Auditorium(int number, AuditoriumType size) {
        this.number = number;
        this.size = size;
    }

    public Auditorium() {
    }

    public int getId() {
        return id;
    }

    public int getNumber() {
        return number;
    }

    public AuditoriumType getSize() {
        return size;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public void setSize(AuditoriumType size) {
        this.size = size;
    }

    public int getAuditoriumCapacity() {
        return size.getCapacity();
    }

    public String getAuditoriumDescription() {
        return size.getDescription();
    }

    public int getAuditoriumType() {
        return size.getType();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Auditorium that = (Auditorium) o;

        if (id != that.id) return false;
        if (number != that.number) return false;
        if (size != that.size) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = number;
        result = 31 * result + size.hashCode();
        result = 31 * result + id;
        return result;
    }

    @Override
    public String toString() {
        return "Auditorium{" +
                "number=" + number +
                ", size=" + size +
                ", id=" + id +
                '}';
    }

    private int number = 0;
    private AuditoriumType size = AuditoriumType.SMALL_AUDITORIUM;
    private int id;
    private static int nextId = 400000000; // 4 prefix will show that it is an auditorium

    {
        id = nextId;
        number = nextId;
        nextId++;
    }
}
